using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using EditWebSite.Logics;

namespace EditWebSite.Presentation
{
    public partial class FrmNuovoUtente : Form
    {
        #region CONSTRUCTOR
        public FrmNuovoUtente()
        {
            InitializeComponent();
        }
        #endregion

        #region PROPERTY
        public string Username
        {
            get { return txtLogin.Text.Trim(); }
        }

        public string Password
        {
            get
            {
                return MD5Helper.GetMd5FromString(txtPassword.Text.Trim());
            }
        }

        public int Livello
        {
            get { return cmbLivello.SelectedIndex + 1; }
        }
        #endregion

        #region METHODS
        private void btnAnnulla_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtLogin.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Manca lo user name!", "Attenzione", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtLogin.Focus();
                return;
            }
            if (txtPassword.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Manca la password!", "Attenzione", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
                return;
            }
            if (cmbLivello.SelectedIndex == -1)
            {
                MessageBox.Show("Manca il livello!", "Attenzione", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmbLivello.Focus();
                return;
            }
            this.DialogResult = DialogResult.OK;
        }
        #endregion


    }
}